package com.gxa.controller.shezhicontroller;

import com.gxa.common.R;
import com.gxa.pojo.KeHuType;
import com.gxa.service.shezhiservice.KeHuType46Service;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author x
 */
@RestController
@RequestMapping("/KeHuType")
@Api(value = "客户类别管理" , tags = "客户类别数据接口API")
@RequiresPermissions("客户类别")
public class KeHuTypeController {

    @Autowired(required = false)
    public R r;

    @Autowired(required = false)
   public KeHuType46Service keHuType46Service;

    @GetMapping("/selectAllKeHuTypeForPage")
    @ApiOperation(value = "客户查询接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "get",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示条数", required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })

    public R selectAllKeHuTypeForPage(@RequestParam int page,@RequestParam int size)

    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        ArrayList<Object> list = new ArrayList<>();
//        list.add("jjj");
//        r.setData(list);
//        return r;
       return keHuType46Service.selectAllKeHuTypeForPage( page , size );
    }
    @GetMapping("/selectKeHuTypeByType")
    @ApiOperation(value = "客户查询接口（根据条件查询）",notes="提供当前页码与每页显示条数，客户类别",httpMethod = "get",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示条数", required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "keHuType",value = "客户类别",required = false,dataType = "String",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R selectkeHuTypeByType(@RequestParam int page,@RequestParam int size,String keHuType)
    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
////        虚拟接口
//        ArrayList<Object> list = new ArrayList<>();
//        KeHuType keHuType1 = new KeHuType();
//        keHuType1.setKeHuType("66");
//        list.add(keHuType1);
//        r.setData(list);
//        return r;
        return keHuType46Service.selectKeHuTypeByType(page ,size ,keHuType);
    }
    @PostMapping("/insertKeHuType")
    @ApiOperation(value = "新增客户接口",notes="提供客户信息",httpMethod = "post",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R insertKeHuType(@RequestBody KeHuType keHu)
    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        //        虚拟接口
//        ArrayList<Object> list = new ArrayList<>();
//        KeHuType keHuType2 = new KeHuType();
//        keHuType2.setKeHuType("66");
//        list.add(keHuType2);
//        r.setData(list);
//        return r;
        return keHuType46Service.insertKeHuType(keHu);
    }

    @PostMapping("/updateKeHuTypeById")
    @ApiOperation(value = "修改客户信息接口",notes="提供客户信息",httpMethod = "post",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateKeHuTypeById(@RequestBody KeHuType keHu)
    {
//        r.setCode(200);
//        r.setMsg("修改成功！");
//        //        虚拟接口
//        ArrayList<Object> list = new ArrayList<>();
//        KeHuType keHuType3 = new KeHuType();
//        keHuType3.setId(777);
//        list.add(keHuType3);
//        r.setData(list);
//        return r;
        return keHuType46Service.updateKeHuTypeById(keHu);
    }

    @PostMapping("/deleteKeHuTypeById")
    @ApiOperation(value = "删除客户接口",notes = "提供客户id",httpMethod = "post",response = R.class)
    @ApiImplicitParam(name="id",value = "主键",required = true,dataType = "int")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteKeHuTypeById(@RequestParam int id)
    {
//        r.setCode(200);
//        r.setMsg("删除成功！");
//        //        虚拟接口
//        ArrayList<Object> list = new ArrayList<>();
//        KeHuType keHuType4 = new KeHuType();
//        keHuType4.setKeHuType("66");
//        list.add(keHuType4);
//        r.setData(list);
//        return r;
        return keHuType46Service.deleteKeHuTypeById(id);



        }



}
